/*
*
==============================================================================
*  Name        : 
*  Part of     : Omen Game Engine
*  Description : 
*  Version     : 1.0
*
*  Copyright (c) 2013 Lauri Kortevaara.
* 
==============================================================================
*/

#define OMEN_SOURCE 1

#include "OmenInputServer.h"

using namespace Omen;


/// <summary>Releases the resources of the Input server</summary>
InputServer::~InputServer()
{
    for( InputDriverVector::const_iterator it = InputDrivers.begin();
         it != InputDrivers.end();  ++it ) 
    {
        delete *it;
    }
}

/// <summary>Allows plugins to add new Input drivers</summary>
/// <param name="IInputDriver">Input driver that will be added</param>
void InputServer::addInputDriver( Omen::IInputDriver* pInputDriver) 
{
    InputDrivers.push_back(pInputDriver);
}

/// <summary>Gets the total number of registered Input drivers</summary>
size_t InputServer::getDriverCount() const 
{
    return InputDrivers.size();
}

/// <summary>Accesses a driver by its index</summary>
IInputDriver& InputServer::getDriver(size_t index) 
{
    return *InputDrivers.at(index);
}

void InputServer::handleInput() const
{
    for( InputDriverVector::const_iterator it = InputDrivers.begin();
         it != InputDrivers.end();  ++it ) 
    {
        (*it)->handleInput();
    }
}